package com.liuyucheng.idea_springboot;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;

import java.net.InetAddress;

@Slf4j
@EnableAsync(proxyTargetClass=true)
@SpringBootApplication
public class IdeaSpringBootApplication {

    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(IdeaSpringBootApplication.class, args);

        try {
            String ip = InetAddress.getLocalHost().getHostAddress();
            Environment environment = context.getEnvironment();
            String port = environment.getProperty("server.port");
            String path = environment.getProperty("server.servlet.context-path");

            log.info("Server: http://"+ip+":"+port+path+"/");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
